var mysql = require('mysql');

var client = mysql.createConnection({
  host: 'localhost',
  user: 'lupeng',
  password: '080910',
  database: 'myapp'
});

client.connect();



// 增加记录
client.query('insert into test (username ,password) values ("sunli" , "123456")');

// 删除记录
client.query('delete from test where username = "sunli"');

// 修改记录
client.query('update test set username = "pengloo53" where username = "lupeng"');

// 查询记录
client.query("select * from test" , function selectTable(err, rows, fields){
  if (err){
    throw err;
  }
  if (rows){
    for(var i = 0 ; i < rows.length ; i++){
      console.log("%d\t%s\t%s", rows[i].id,rows[i].username,rows[i].password);
    }
  }
});

client.end();
